<% if @total == 0 %>
    
    <p>No documents found...</p>
    
<% else %>

    <% assoc_names = Document.reflections.values.every(:name).join(",").split(",") %>
    <p>Number of documents found : <b><%= @total %></b></p>
    
  <div id="report-bottom-panel">
    <%= link_to image_tag('page_white_excel.png', {:title=> 'Export to CSV', :alt =>  'Export to CSV'}), {:action => "show.csv"}, {:popup => true}  %>
  </div> 
  
    <table>
      <thead>
        <tr class="table-header">
          <% @filter_hash.each do |x| %>
            <% column = x[0] %>
            <td <%= sort_td_class_helper "#{column}" %>>
              <%= sort_link_helper "#{column}".titleize, "#{column}" %>
            </td>
          <% end %>
       </tr>
      </thead>
      <tbody>
        <% @documents.each do |i| %>
        <tr class="report<%= cycle("even","odd") %>">
          <% @filter_hash.each do |x| %>
            <% column = x[0] %>
            <% if column.in? assoc_names %>
                <td><%= i.send(column).name rescue "none" %></td>
            <% else %>
                <% c = i.send(column) rescue "none"  %>
                <td> <%= link_to c, {:controller => "documents", :action => "show", :id => i.id}, {:popup => true} %></td>
            <% end %>
          <% end %>
       </tr>
        <% end %>
      </tbody>
    </table>
    <p>
<% if @documents_pages.page_count > 1 %>
Page&nbsp;:
<%= pagination_links_remote @documents_pages %>
<% end %>
</p>

<% end %>
